﻿<Navbar Theme="NavbarTheme.Dark" Mode="NavbarMode.VerticalMixin" CollapseMode="NavbarCollapseMode.Small" VerticalZindex="1200">
    <NavbarBrand>
        <NavbarItem>
            <NavbarLink>
                <NavbarIcon UseCustom>
                    <img src="_content/BPM.Web.Shared/images/logo.png" class="bpm-logo"/>
                </NavbarIcon>
                Admin.NET.Blazor
            </NavbarLink>
        </NavbarItem>
    </NavbarBrand>
    
    <NavbarMenu>
        <NavbarGroup>
            @foreach(var item in State.Menus)
            {
                <NavbarItem>
                    @if (item.Items.Any())
                    {
                        @RenderSubMenu(item)
                    }
                    else{
                        <NavbarLink Title="@item.Text" To="@item.Url">
                            <NavbarIcon IconName="@item.Icon">@item.Text</NavbarIcon>
                        </NavbarLink>
                    }
                </NavbarItem>                            
            }
        </NavbarGroup>

        <NavbarGroup IsTail>
            <NavbarItem>
                <NavbarDropdown>
                    <NavbarDropdownToggle>
                        <NavbarIcon IconName="fa fa-fw fa-circle-o glow">文档资料</NavbarIcon>
                    </NavbarDropdownToggle>
                    <NavbarDropdownMenu>
                        <NavbarDropdownItem To="https://docs.microsoft.com/zh-cn/aspnet/core/blazor/" Target="NavLinkTarget.Blank">Microsoft Blazor</NavbarDropdownItem>
                        <NavbarDropdownItem To="https://www.blazor.zone/components" Target="NavLinkTarget.Blank">BootstrapBlazor</NavbarDropdownItem>
                        <NavbarDropdownItem To="https://v5.bootcss.com/docs/utilities/borders/" Target="NavLinkTarget.Blank">Bootstrap V5</NavbarDropdownItem>
                        <NavbarDropdownItem To="http://www.fontawesome.com.cn/faicons/" Target="NavLinkTarget.Blank">fontawesome</NavbarDropdownItem>
                        <NavbarDropdownItem To="https://github.com/dotnetcore/WebApiClient/wiki" Target="NavLinkTarget.Blank">WebApiClient</NavbarDropdownItem>
                        <NavbarDropdownItem To="https://dotnetchina.gitee.io/furion/docs/" Target="NavLinkTarget.Blank">furion</NavbarDropdownItem>
                        <NavbarDropdownItem To="http://freesql.net/guide/" Target="NavLinkTarget.Blank">FreeSql</NavbarDropdownItem>
                        <NavbarDropdownItem To="https://clickhouse.com/docs/zh/" Target="NavLinkTarget.Blank">clickhouse</NavbarDropdownItem>
                    </NavbarDropdownMenu>
                </NavbarDropdown>
            </NavbarItem>
        </NavbarGroup>
    </NavbarMenu>

</Navbar>


@code {
        
    /// <summary>
    /// 当前会话状态
    /// </summary>
    [CascadingParameter]
    public SessionState State { get; set; } = new();

    /// <summary>
    /// 渲染子菜单
    /// </summary>
    RenderFragment<MenuItem> RenderSubMenu => menu => 
    @<NavbarDropdown>
        <NavbarDropdownToggle>
            @if (string.IsNullOrWhiteSpace(menu.Icon))
            {
                @menu.Text
            }
            else
            {   
                <NavbarIcon IconName="@menu.Icon">@menu.Text</NavbarIcon>  
            }
        </NavbarDropdownToggle>

        <NavbarDropdownMenu>
            @foreach(var item in menu.Items)
            {
                @if (item.Items.Any())
                {
                    @RenderSubMenu(item)
                }
                else
                {   
                    <NavbarDropdownItem To="@item.Url">@item.Text</NavbarDropdownItem>    
                }    
            }
        </NavbarDropdownMenu>
    </NavbarDropdown>;
}